{% extends 'base.html' %}
{% load staticfiles %}

{% block title %}公开课详情 - 谷粒教育网{% endblock %}

{% block content %}
    <section>
        <div class="wp">
            <div class="crumbs">
                <ul>
                    <li><a href="/">首页</a>></li>
                    <li><a href="{% url 'courses:course_list' %}">公开课程</a>></li>
                    <li>课程详情</li>
                </ul>
            </div>
        </div>
    </section>
    <section>
        <div class="wp">
            <div class="groupPurchase_detail detail">
                <div class="toppro">
                    <div class="left">
                        <div class="picbox">
                            <div class="tb-booth tb-pic">
                                <img width="440" height="445" src="{{ MEDIA_URL }}{{ course.image }}" class="jqzoom" />
                            </div>

                        </div>
                        <div class="des">
                            <h1 title="{{ course.name }}">{{ course.name }}</h1>
                            <span class="key">{{ course.desc }}</span>
                            <div class="prize">
                                <span class="fl">难度：
                                    <i class="key">
                                        {% if course.level == 'gj' %}
                                            高级
                                        {% elif course.level == 'zj' %}
                                            中级
                                        {% else %}
                                            初级
                                        {% endif %}
                                    </i>
                                </span>
                                <span class="fr">学习人数：{{ course.study_num }}</span>
                            </div>
                            <ul class="parameter">
                                <li><span class="pram word3">时&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;长：</span><span>{{ course.study_time }}</span></li>
                                <li><span class="pram word3">章&nbsp;节&nbsp;数：</span><span>{{ course.lessoninfo_set.count }}</span></li>
                                <li><span class="pram word3">课程类别：</span>
                                    <span title="">
                                        {% if  course.category == 'qd' %}
                                            web开发
                                        {% else %}
                                            后端开发
                                        {% endif %}
                                    </span>
                                </li>
                                <li class="piclist"><span class="pram word4">学习用户：</span>
                                {% for usercourse in course.usercourse_set.all|slice:":5" %}
                                    <span class="pic"><img width="40" height="40" src="{{ MEDIA_URL }}{{ usercourse.study_man.image }}"/></span>
                                {% endfor %}
                                </li>
                            </ul>
                            <div class="btns">
                                <div class="btn colectgroupbtn"  id="jsLeftBtn">
                                    {% if lovecourse %} 取消收藏 {% else %} 收藏 {% endif %}
                                </div>
                                <div class="buy btn"><a style="color: white" href="{% url 'courses:course_video' course.id %}">开始学习</a></div>
                            </div>
                        </div>
                    </div>
                    <div class="right">
                        <div class="head">
                            <h1>授课机构</h1>
                            <p>世界名校，课程权威</p>
                        </div>
                        <div class="pic">
                            <a href="{% url 'orgs:org_detail' course.orginfo.id %}">
                                <img width="150" height="80" src="{{ MEDIA_URL }}{{ course.orginfo.image }}"/>
                            </a>
                        </div>
                        <a href="{% url 'orgs:org_detail' course.orginfo.id %}">
                            <h2 class="center" title="{{ course.orginfo.name }}">{{ course.orginfo.name }}</h2>
                        </a>
                        <div class="btn  notlogin
					     "data-favid="14" id="jsRightBtn">
                            {% if loveorg %} 取消收藏 {% else %} 收藏 {% endif %}
                        </div>
                        <div class="clear">
                            <ul>
                                <li>
                                    <span>课 &nbsp;程&nbsp; 数：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   {{ course.orginfo.course_num }}</span>
                                </li>
                                <li>
                                    <span>教 &nbsp;师&nbsp; 数：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  {{ course.orginfo.teacherinfo_set.count }}</span>
                                </li>
                                <li>所在地区：&nbsp;&nbsp;{{ course.orginfo.cityinfo.name }}</li>
                                <li>认&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;证&nbsp;:
                                    &nbsp;&nbsp;
                                    <img title="金牌机构", src="{% static 'images/gold.png' %}"/>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
    <section>
        <div class="wp">
            <div class="list groupPurchase_detail_pro">
                <div class="left layout">
                    <div class="head">
                        <ul class="tab_header">
                            <li class="active">课程详情</li>
                        </ul>
                    </div>
                    <div class="tab_cont tab_cont1">
                        <p>{{ course.detail }}</p>
                    </div>
                </div>
                <div class="right layout">
                    <div class="head">相关课程推荐</div>
                    <div class="group_recommend">
                        <dl>
                            <dt>
                                <a target="_blank" href="{% url 'courses:course_detail' relate_course.id %}">
                                    <img width="240" height="220" class="scrollLoading" src="{{ MEDIA_URL }}{{ relate_course.image }}"/>
                                </a>
                            </dt>
                            <dd>
                                <a target="_blank" href="{% url 'courses:course_detail' relate_course.id %}"><h2>{{ relate_course.name }}</h2></a>
                                <span class="fl">学习时长：<i class="key">{{ relate_course.study_time }}</i></span>
                            </dd>
                        </dl>
                    </div>
                </div>
            </div>
        </div>
    </section>
{% endblock %}

{% block myjs %}
<script>
 // 页面加载
 $(function () {
     // 课程详情页左边的课程收藏
     $('#jsLeftBtn').click(function () {
         var loveid = {{ course.id }};
         var lovetype = 2;  // 2 表示课程收藏
         $.ajax({
             url: '{% url 'operations:user_love'%}',
             type: 'GET',
             data:{
                 loveid: loveid,
                 lovetype: lovetype,
             },
             success:function (callback) {
                if (callback.status == 'ok'){
                    $('#jsLeftBtn').text(callback.msg)
                }else{
                    alert(callback.msg)
                }
             }

         });
     });
     // 课程详情页右边的机构收藏
     $('#jsRightBtn').click(function () {
         var loveid = {{ course.orginfo.id }};
         var lovetype = 1;  // 1 表示机构收藏
         $.ajax({
             url: '{% url 'operations:user_love'%}',
             type: 'GET',
             data:{
                 loveid: loveid,
                 lovetype: lovetype,
             },
             success:function (callback) {
                 if (callback.status == 'ok'){
                     $('#jsRightBtn').text(callback.msg)
                 }else{
                     alert(callback.msg)
                 }
             }

         });
     });
 });

</script>
{% endblock %}
